import fetch from 'utils/fetch'

export default {
  getPlanList (params) { // 获取训练计划列表
    return fetch({
      url: '/train/plan/trainPlanInfoList',
      params
    })
  },
  addPlanTemplate (data, options) { // 新增训练计划模板
    return fetch({
      url: '/train/plan/addTrainPlanInfo',
      method: 'POST',
      data,
      options
    })
  },
  deletePlan (params, options) { // 删除训练计划模板
    return fetch({
      url: '/train/plan/delTrainPlan',
      method: 'delete',
      params,
      options
    })
  },
  clonePlanTemp (data, options) { // 复制训练计划模板
    return fetch({
      url: '/train/plan/duplicationTrainPlan',
      method: 'POST',
      data,
      options
    })
  },
  previewPlanTemp (data, options) { // 预览训练计划模板
    return fetch({
      url: '/train/plan/getTrainStyle',
      method: 'POST',
      data,
      options
    })
  },
  checkPlanTemp (data, options) { // 审核训练计划
    return fetch({
      url: '/train/plan/reviewTrainPlan',
      method: 'POST',
      data,
      options
    })
  },
  editPlanTemp (data, options) { // 编辑训练计划模板
    return fetch({
      url: '/train/plan/updTrainPlan',
      method: 'POST',
      data,
      options
    })
  },
  getSingleTemp (params) { // 获取单个训练计划模板
    return fetch({
      url: '/train/plan/TrainPlanFullInfoVO',
      params
    })
  },
  getPlanTempList (params) { // 编辑时根据Id查询当前训练计划的训练方式列表
    return fetch({
      url: '/train/plan/list/trainStyleInfo',
      params
    })
  },
  searchSport (params) { // 查找训练方式
    return fetch({
      url: '/train/training/style/list/type/sport',
      params
    })
  },
  addTrainStyle (data, options) { // 新增训练方式
    let query = ''
    if (options.type === 'DELETE') {
      query = `?id=${data.id}`
    } else if (options.type === 'GET') {
      query = `?id=${data.id}`
    }
    return fetch({
      url: '/train/training/style/' + query,
      method: options.type,
      data,
      options
    })
  },
  searchStyleList (params) { // 训练方式列表
    return fetch({
      url: '/train/training/style/list',
      params
    })
  },
  setYesAudit (data, options) { // 审核通过训练方式
    return fetch({
      url: '/train/training/style/audit',
      method: 'PUT',
      data,
      options
    })
  },
  setNoAudit (data, options) { // 拒绝审核训练方式
    return fetch({
      url: '/train/training/style/audit/not',
      method: 'PUT',
      data,
      options
    })
  },
  setResubmitAudit (data, options) { // 重新提交训练方式
    return fetch({
      url: '/train/training/style/redo',
      method: 'PUT',
      data,
      options
    })
  },
  getDeleteBef (params, options) { // 删除模板之前判断是否应用了模板
    return fetch({
      url: '/train/plan/delPretrainPlan',
      params,
      options
    })
  },
  selectedTemp (data, options) {
    let method = options.type || (data.id ? 'PUT' : 'POST')
    let query = method === 'DELETE' ? '?id=' + data.id : ''
    return fetch({
      url: '/train/schedule/drillplan' + query,
      method,
      data,
      options
    })
  },
  checkTopicName (params, options) { // 校验课时主题是否重复
    return fetch({
      url: '/train/plan/checkTopicName',
      params,
      options
    })
  }
}
